import * as echarts from 'echarts/core';
import {
    BarChart,
    // 系列类型的定义后缀都为 SeriesOption
    BarSeriesOption,
    LineChart,
    HeatmapChart,
    LineSeriesOption
} from 'echarts/charts';
import {
    TitleComponent,
    // 组件类型的定义后缀都为 ComponentOption
    TitleComponentOption,
    TooltipComponent,
    TooltipComponentOption,
    VisualMapComponent,
    VisualMapComponentOption,
    CalendarComponent,
    CalendarComponentOption,
    GridComponent,
    GridComponentOption
} from 'echarts/components';
import {
    CanvasRenderer
} from 'echarts/renderers';

// 通过 ComposeOption 来组合出一个只有必须组件和图表的 Option 类型
type ECOption = echarts.ComposeOption<
    BarSeriesOption | LineSeriesOption | TitleComponentOption |
    GridComponentOption | TooltipComponentOption | VisualMapComponentOption | CalendarComponentOption
>;

// 注册必须的组件
echarts.use(
    [TitleComponent, HeatmapChart, TooltipComponent,
        GridComponent, BarChart, CanvasRenderer, LineChart, VisualMapComponent, CalendarComponent]
);

export { echarts, ECOption }